// 请求用户信息模块

// 用户登录请求
import request from '@/utils/request'
export const login = data => {
  return request({
    method: 'post',
    url: '/app/v1_0/authorizations',
    data
  })
}

// 获取验证码
export const sendSms = mobile => {
  return request({
    method: 'get',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}

// 获取用户信息
export const UserInfo = () => {
  return request({
    method: 'get',
    url: '/app/v1_0/user'
  })
}

// 获取用户频道
export const getUserchannels = () => {
  return request({
    method: 'get',
    url: '/app/v1_0/user/channels'
  })
}

// 关注用户
export const attentionUser = target	=> {
  return request({
    method: 'post',
    url: '/app/v1_0/user/followings',
    data: {
      target
    }
  })
}

// 取消关注用户
export const cancelAttention = target => {
  return request({
    method: 'delete',
    url: `/app/v1_0/user/followings/${target}`
  })
}

// 收藏文章
export const collectArticle = target => {
  return request({
    method: 'post',
    url: '/app/v1_0/article/collections',
    data: {
      target
    }
  })
}

// 取消收藏文章
export const cancelArticle = target => {
  return request({
    method: 'delete',
    url: `/app/v1_0/article/collections/${target}`
  })
}

// 点赞文章
export const likeArticle = target => {
  return request({
    method: 'post',
    url: '/app/v1_0/article/likings',
    data: {
      target
    }
  })
}

// 取消点赞文章
export const cancelLike = target => {
  return request({
    method: 'delete',
    url: `/app/v1_0/article/likings/${target}`
  })
}

// 获取用户个人信息
export const getUserinfo = target => {
  return request({
    method: 'get',
    url: '/app/v1_0/user/profile'
  })
}

// 修改用户个人信息
export const editUserinfo = data => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data
  })
}

// 修改用户头像
export const editUserImg = data => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data
  })
}
